package edu.map.aamas.charts;

import java.util.Vector;

import javax.swing.JFrame;

import edu.map.aamas.rnn.RNN;

public class ActuationChart extends RnnChart {
	
	private static final long serialVersionUID = 1L;

	private static String[] getMuscleNames(RNN rnr) {
		Vector<String> muscles = new Vector<String>();
		
		for (int i = 1; i <= rnr.numMuscles; i++)
			muscles.add("muscle "+i);
		
		return muscles.toArray(new String[]{});			
	}
	
	public ActuationChart(RNN rnr) {
		super(rnr, getMuscleNames(rnr));
	}
	
	public void rnnUpdated(RNN rnr) {
		double[] vals = new double[rnr.numMuscles];
		
		for (int i = 0; i < rnr.numMuscles; i++)
			vals[i] = rnr.C[i];
		update(vals);
	}
	
	public static void main(String[] args) throws Exception{
		JFrame test = new JFrame("test");		
		RNN rnr = RNN.getInstance(48);
		ActuationChart chart = new ActuationChart(rnr);
		
		rnr.addRnrListener(chart);
		test.setSize(400, 100);
		test.add(chart);
		test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		test.setVisible(true);
		
		while (true) {
			rnr.update();
			Thread.sleep(10);
		}
	}
}
